package com.codejiwei.flink.sql;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @author jiwei
 * @description
 * @date 2023/5/25 14:25
 */
public class Flink_SQL_DataGen2Print {
    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(10);
        StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);

        tableEnv.executeSql("CREATE TABLE Orders (\n" +
                "    order_number BIGINT,\n" +
                "    price        DECIMAL(32,2),\n" +
                "    s1        STRING,\n" +
                "    buyer        ROW<first_name STRING, last_name STRING>,\n" +
                "    eventTime   TIMESTAMP(3)\n" +
                ") WITH (\n" +
                "  'connector' = 'datagen'\n" +
                ")");

        tableEnv.executeSql("CREATE TABLE print_table WITH ('connector' = 'print')\n" +
                "LIKE Orders (EXCLUDING ALL)");

        tableEnv.executeSql("insert into print_table select * from Orders");


    }
}
